<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
	Object obj = request.getSession().getAttribute("role_resource");
	if (null == obj) {
		response.setStatus(1000);
		return;
	}
%>
	
<script type="text/javascript">

	var uploadForm = new Ext.form.FormPanel({
		id : "uploadForm",
		border:false,
		fileUpload : true,
		labelAlign : "left",
		frame: true,
		bodyStyle : "padding: 10px 10px 10px 10px;",
		items : [  {
			xtype : "fileuploadfield",
			fieldLabel : "退件文件",
			emptyText : "请选择文件",
			name : "file",
			allowBlank: false,
			anchor : "50%",
			validator:function (input){
				if(input=='')return false;
				var lx=input.substring(input.lastIndexOf(".")+1);
				if(lx=='txt'){
					return true;
				}else{
					return "只限上传txt文件！";
				}
			}
		}, {
			xtype : "button",
			text : "上传文件",
			handler : function() {
					if (Ext.getCmp("uploadForm").getForm().isValid()) {
						Ext.getCmp("uploadForm").getForm().submit( {
							url : 'upload2!backLetter.action',
							waitMsg : '正在上传文件...',
							success : function(fp, o) {
								if(o==null || o.result.msg==''){
									Ext.Msg.show( {
										title : 'Success',
										msg : '文件读取成功！',
										minWidth : 200,
										modal : true,
										icon : Ext.Msg.INFO,
										buttons : Ext.Msg.OK
									});
								}else{
									var tt=o.result.msg;
									var flag=true;
									while(flag){
									    if(tt.indexOf("！")==-1){
									        flag=false;
									    }else{
									    tt=tt.replace("！","!</p>");
									}
									}
									Ext.Msg.show( {
										title : 'Failure',
										msg : tt,
										minWidth : 200,
										modal : true,
										icon : Ext.Msg.INFO,
										buttons : Ext.Msg.OK
									});
								}
							}
						});
					}else{
						Ext.Msg.show( {
										title : 'Success',
										msg : '验证不通过！',
										minWidth : 200,
										modal : true,
										icon : Ext.Msg.INFO,
										buttons : Ext.Msg.OK
									});
					}
				}
			}]
	});
	
	
	var CenterPanel=Ext.getCmp("CenterPanel");
	CenterPanel.removeAll();
	CenterPanel.add(uploadForm);
	CenterPanel.doLayout();
</script>